package com.vvlive.caibao.smartcity.utils;

import android.annotation.SuppressLint;
import android.view.View;
import android.view.ViewPropertyAnimator;
import android.view.animation.Interpolator;

/**
 * Created by zhj on 2015/7/4.
 */
@SuppressLint("NewApi")
public class ViewAnimatorUtil {

    public static ViewPropertyAnimator translate(View target, long duration, int x){
        return translate(target, duration, x, null);
    }

    public static ViewPropertyAnimator translate(View target, long duration, int x, Interpolator interpolator){
        return target.animate().translationX(x).setInterpolator(interpolator).setDuration(duration);
    }

    public static ViewPropertyAnimator slide(View target, long duration, int y){
        return slide(target, duration, y, null);
    }

    public static ViewPropertyAnimator slide(View target, long duration, int y, Interpolator interpolator){
        return target.animate().translationY(y).setDuration(duration).setInterpolator(interpolator);
    }

    public static ViewPropertyAnimator fade(View target, float value, long duration){
        return fade(target, value, duration, null);
    }

    public static ViewPropertyAnimator fade(View target, float value, long duration, Interpolator interpolator){
        return target.animate().alpha(value).setInterpolator(interpolator).setDuration(duration);
    }
}
